package com.model.defaults.tabsheet.entities;

import java.util.Map;

import org.hibernate.Session;

import com.core.utils.GlobalConstants;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.TabSheetItem;
import com.model.UserContextName;


public class ModelDefaultTabsheetProject {

	public static void createTabsheetItemsProject ( Session session,
	                                                Map <String, UserContextName> userContexts ) {

		ModelDefaultTabsheetProject.createTabsheetItemsProjectBrowse(session, userContexts);

		ModelDefaultTabsheetProject.createTabsheetItemsProjectOpen(session, userContexts);

		ModelDefaultTabsheetProject.createTabsheerItemsProjectOpenIssues(session, userContexts);

		ModelDefaultTabsheetProject.createTabsheerItemsProjectOpenVersion(session, userContexts);

		ModelDefaultTabsheetProject.createTabsheerItemsProjectOpenTeam(session, userContexts);
	}



	private static void createTabsheetItemsProjectBrowse ( Session session,
	                                                       Map <String, UserContextName> userContexts ) {

		TabSheetItem pojo = null;
		UserContextName visibleInContextName_1 = null;
		UserContextName userContextNameToExecute = null;

		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;


		actionScript = new ActionScript();
		actionScript.setActionScriptText("BrowseProjects?{selectedTab}");
		actionScript.setActionScriptType("servlet");

		actionScriptParam = new KeyValue("selectedTab", "selectedTab=1");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_DASHBOARD);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTSLIST);
		pojo = new TabSheetItem();
		pojo.setName("tabsheet.projects.projectslist");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setJspNameInContext("details/tabProjectsList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTLIST);
		pojo.setActionScript(actionScript);
		session.save(pojo);

		/**
         *
         */

		actionScript = new ActionScript();
		actionScript.setActionScriptText("%s?{selectedTab}", GlobalConstants.SERVLET_PROJECTLIST);
		actionScript.setActionScriptType("servlet");

		actionScriptParam = new KeyValue("selectedTab", "selectedTab=2");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTSLIST);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_REPORTSLIST);
		pojo = new TabSheetItem();
		pojo.setName("tabsheet.projects.filters");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setJspNameInContext("details/tabProjectFiltersList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTLIST);
		pojo.setActionScript(actionScript);
		session.save(pojo);
	}



	private static void createTabsheerItemsProjectOpenIssues ( Session session,
	                                                           Map <String, UserContextName> userContexts ) {

		TabSheetItem pojo = null;
		UserContextName visibleInContextName_1 = null;
		UserContextName userContextNameToExecute = null;

		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;

		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("t1", "selectedTab=2");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("%s?{p2}&{t1}", GlobalConstants.SERVLET_PROJECTINFO);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTINFO);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_TASKSLIST);
		pojo = new TabSheetItem();
		pojo.setName("tabsheet.projectitem.issues");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setJspNameInContext("details/tabProjectTasksList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTINFO);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setActionScript(actionScript);
		session.save(pojo);
	}



	private static void createTabsheerItemsProjectOpenVersion ( Session session,
	                                                            Map <String, UserContextName> userContexts ) {

		TabSheetItem pojo = null;
		UserContextName visibleInContextName_1 = null;
		UserContextName userContextNameToExecute = null;

		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;

		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("t1", "selectedTab=3");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("%s?{p2}&{t1}", GlobalConstants.SERVLET_PROJECTINFO);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTINFO);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_VERSIONSLIST);

		pojo = new TabSheetItem();
		pojo.setName("tabsheet.projectitem.versions");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setJspNameInContext("details/tabProjectVersionsList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTINFO);
		pojo.setActionScript(actionScript);
		session.save(pojo);
	}



	private static void createTabsheetItemsProjectOpen ( Session session,
	                                                     Map <String, UserContextName> userContexts ) {

		/*
		 * OpenProject
		 */

		TabSheetItem pojo = null;
		UserContextName visibleInContextName_1 = null;
		UserContextName userContextNameToExecute = null;

		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;


		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("t1", "selectedTab=1");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("%s?{p2}&{t1}", GlobalConstants.SERVLET_PROJECTINFO);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTINFO);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTINFO);
		pojo = new TabSheetItem();
		pojo.setName("tabsheet.projectitem.description");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setJspNameInContext("details/tabProjectInfo.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTINFO);
		pojo.setActionScript(actionScript);
		session.save(pojo);

	}



	private static void createTabsheerItemsProjectOpenTeam ( Session session,
	                                                         Map <String, UserContextName> userContexts ) {

		TabSheetItem pojo = null;
		UserContextName visibleInContextName_1 = null;
		UserContextName userContextNameToExecute = null;

		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;

		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("t1", "selectedTab=4");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("%s?{p2}&{t1}", GlobalConstants.SERVLET_PROJECTINFO);
		session.save(actionScript);

		visibleInContextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTINFO);
		userContextNameToExecute = userContexts.get(GlobalConstants.USERCONTEXT_TEAMMEMBERLIST);

		pojo = new TabSheetItem();
		pojo.setName("tabsheet.projectitem.team");
		pojo.getUserContextNameVisibleIn().add(visibleInContextName_1);
		pojo.setUserContextNameToExecute(userContextNameToExecute);
		pojo.setJspNameInContext("details/tabProjectTeamList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTINFO);
		pojo.setActionScript(actionScript);
		session.save(pojo);
	}


}
